﻿using System.ComponentModel;

namespace BlamanticUI.Components;

/// <summary>
/// Render a div tag as card layout.
/// </summary>
[CssClass("card")]
public class Card : BlazorChildContentComponentBase, IHasUI, IHasFluid, IHasCentered, IHasHorizontal, IHasLinked, IHasColor
{
    /// <summary>
    /// Initializes a new instance of the <see cref="Card"/> class.
    /// </summary>
    public Card()
    {
        UI = CascadingCardGroup is null;
    }

    /// <summary>
    /// Gets or sets component can be UI component. default is <c>true</c>.
    /// </summary>
    /// <value>
    ///   <c>true</c> to be UI component,otherwise <c>false</c>.
    /// </value>
    public bool UI { get; set; }

    /// <summary>
    /// Gets or sets the parent.
    /// </summary>
    [CascadingParameter] CardGroup CascadingCardGroup { get; set; }
    /// <summary>
    /// Gets or sets a value indicating whether this is fluid.
    /// </summary>
    /// <value>
    ///   <c>true</c> if fluid; otherwise, <c>false</c>.
    /// </value>
    [Parameter] public bool Fluid { get; set; }
    /// <summary>
    /// Gets or sets a value indicating whether alighment is centered in container.
    /// </summary>
    /// <value>
    ///   <c>true</c> if centered; otherwise, <c>false</c>.
    /// </value>
    [Parameter] public bool Centered { get; set; }
    /// <summary>
    /// Gets or sets a value indicating whether this is horizontal layout.
    /// </summary>
    /// <value>
    ///   <c>true</c> if horizontal; otherwise, <c>false</c>.
    /// </value>
    [Parameter] public bool Horizontal { get; set; }

    /// <summary>
    /// Gets or sets a value indicating whether this <see cref="Card"/> has shadow.
    /// </summary>
    [Parameter] [CssClass("raised")] public bool Shadow { get; set; }
    /// <summary>
    /// Gets or sets a value indicating whether this is linked style.
    /// </summary>
    /// <value>
    ///   <c>true</c> if linked; otherwise, <c>false</c>.
    /// </value>
    [Parameter] public bool Linked { get; set; }
    /// <summary>
    /// Gets or sets the link of uri.
    /// </summary>
    [Parameter][HtmlAttribute("href")] public string Link { get; set; }
    /// <summary>
    /// Gets or sets the color.
    /// </summary>
    [Parameter] public Color? Color { get; set; }

    protected override string TagName => !string.IsNullOrWhiteSpace(Link) ? "a" : "div";
}
